import http from "./index";

export const sendVerificationCode = async (email) => {
    try {
        const response = await http.post('/send-login-code', { email });
        return response.data;
    } catch (error) {
        console.error('发送验证码出错:', error);
        if (error.response) {
            return error.response.data;
        }
        return {
            code: 500,
            message: '发送验证码失败，请检查网络连接'
        };
    }
};

export const verifyVerificationCode = async (email, code) => {
    try {
        const response = await http.post('/verify-code', { email, code });
        return response.data;
    } catch (error) {
        console.error('验证验证码出错:', error);
        if (error.response) {
            return error.response.data;
        }
        return {
            code: 500,
            message: '验证验证码失败'
        };
    }
};

// export default { getList, getDetail ,sendVerificationCode}